package movee.clickhouse.client.controller;

import lombok.extern.slf4j.Slf4j;
import movee.clickhouse.client.dao.ClusterDao;
import movee.clickhouse.client.repository.ClusterRepo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 *
 * @author movee
 */
@RestController
@RequestMapping(value = "/v1/cluster", produces = "application/json")
@Slf4j
public class ClusterController {


    private final ClusterRepo clusterRepo;

    public ClusterController(ClusterRepo clusterRepo) {
        this.clusterRepo = clusterRepo;
    }

    @GetMapping(value = "/list", produces = "application/json")
    public List<ClusterDao> getTotalCluster() {
        log.info("getTotalCluster");
        List<ClusterDao> daos = clusterRepo.findAll();
        log.info("ClusterDao size: {}", daos.size());
        return daos;
    }

}
